<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>微信扫码登录123-生成二维码</title>
  <script src="./wxLogin.js"></script>
  <script src="./jquery.min.js"></script>
</head>

<body>
  <h3 id="head" style="background-color: #69f; padding: 10px; color: #fff;">登录成功： 欢迎
    <a href="/html" style="float: right;">退出登录</a>
  </h3>
  <div id="content" style="border: 1px solid red;">
  </div>
  <div id="weixin" style="border: 1px solid red;"></div>

  <script>
    function getQueryString(key){
        var reg = new RegExp("(^|&)"+key+"=([^&]*)(&|$)");
        var result = window.location.search.substr(1).match(reg);
        return result?decodeURIComponent(result[2]):null;
      }
    let nickname = getQueryString('nickname')
    let headimgurl = getQueryString('headimgurl')
    if (headimgurl) {
      $('#head').show()
      console.log('登录成功回调--',nickname);
      let one = $('<p><img src="'+headimgurl+'"/></p>')
      let one1 = $('<p>'+nickname+'</p>')
      $('#content').append(one)
      $('#content').append(one1)
    } else {
      $('#head').hide()
      // 生成微信二维码工具方法：微信提供的： http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js
      var wx = new WxLogin({
        id: 'weixin',
        appid: "wx7287a60bb700fd21",
        scope: 'snsapi_login',
        redirect_uri: window.decodeURI("http://www.txjava.cn/loginServlet")
      })
    }

  </script>
</body>

</html>